﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using TyMES.Model.BaseInformation;


namespace TyMES.ViewModel.BaseInformation.CustomConfigVMs
{
    public partial class CustomConfigListVM : BasePagedListVM<CustomConfig_View, CustomConfigSearcher>
    {

        protected override IEnumerable<IGridColumn<CustomConfig_View>> InitGridHeader()
        {
            return new List<GridColumn<CustomConfig_View>>{
                this.MakeGridHeader(x => x.customProperty),
                this.MakeGridHeader(x => x.propertyDescribe),
                this.MakeGridHeader(x => x.propertyValue),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<CustomConfig_View> GetSearchQuery()
        {
            var query = DC.Set<CustomConfig>()
                .CheckContain(Searcher.customProperty, x=>x.customProperty)
                .CheckContain(Searcher.propertyDescribe, x=>x.propertyDescribe)
                .CheckContain(Searcher.propertyValue, x=>x.propertyValue)
                .Select(x => new CustomConfig_View
                {
				    ID = x.ID,
                    customProperty = x.customProperty,
                    propertyDescribe = x.propertyDescribe,
                    propertyValue = x.propertyValue,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class CustomConfig_View : CustomConfig{

    }
}
